{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}

{% block title %}表字段维护
{% endblock %}


{% block content %}
<input type="submit" onclick="location.href='/web_db_table_relate?db_id={{ db_id }}'" value="返回表"></input>
<input type="submit" onclick="location.href='/web_table_sql?table_id={{ table_id }}'" value="查看SQL"></input>
<br><br>

<form action="web_table_column_relate?db_id={{ db_id }}&table_id={{ table_id }}" method="post" id="chooseindex" name="chooseindex" class="form-inline">
    <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
    <div class="form-row">
        <div class="form-group col-md-offset-0">
            <label>请选择属性分类</label>
            <select class="form-control" id="categoryid" name="categoryid" onchange="read_index_info_category(this.options[this.options.selectedIndex].value, '{{ db_id }}' ,'{{ csrf_token() }}')">
                <option value="-1">--全部--</option>
                {% if category_data %}
                    {% for foo in category_data %}
                        <option value="{{ foo.id }}">{{ foo.category_name }}</option>
                    {% endfor %}
                {% endif %}
            </select>
        </div>

        <div class="form-group col-md-offset-0">
            <label>请选择指标</label>
            <select class="form-control" id="indexid" name="indexid"></select>
        </div>

    </div>
    <input type="submit" value="提交" />

</form>
<br><br>
    <table class="table table-bordered">
    <tr>
        <th>属性ID</th>
        <th>属性名</th>
        <th>属性数据类型</th>
        <th>属性类型长度</th>
        <th>属性描述</th>

    </tr>
        {% for i in json_data %}
            <tr>
                <td>{{ i.get('id') }}</td>
                <td>{{ i.get('column_name') }}</td>
                <td>{{ i.get('data_type_name') }}</td>
                <td>{{ i.get('data_length') }}</td>
                <td>{{ i.get('column_describe') }}</td>

                <td>
                    <input type="button" onclick="location.href='table_column_relate_modify?id={{ i.get('id') }}&db_id={{ i.get('db_id') }}&table_id={{ i.get('table_id') }}&column_name={{ i.get('column_name') }}&data_type_id={{ i.get('data_type_id') }}&data_length={{ i.get('data_length') }}&column_describe={{ i.get('column_describe') }}&is_valid=0'" value="删除">
                    </input>
                </td>
            </tr>
    {% endfor %}
    </table>

{% endblock %}

{% block scripts  %}
{{ super() }}
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script src="/static/js/my_test.js"></script>
{% endblock %}
